@echo off
echo "==>TAO_ROOT=%TAO_ROOT%"

set PROJECT_PATH="%TAO_ROOT%/orbsvcs/DevGuideExamples/NotifyService/Messenger"

cd %PROJECT_PATH%


@echo off
setlocal

:: 定义要删除的文件列表
set "files=ns.ior Messenger.ior notify.ior"

:: 删除文件
for %%f in (%files%) do (
    if exist "%%f" (
        echo Deleting %%f...
        del "%%f"
        if not errorlevel 1 (
            echo Deleted %%f successfully.
        ) else (
            echo Error deleting %%f.
        )
    ) else (
        echo %%f does not exist. Skipping.
    )
)

:: 遍历文件列表并删除存在的文件
for %%f in (%files%) do (
    if exist "%%f" (
        echo Deleting %%f...
        del "%%f"
        if not errorlevel 1 (
            echo Deleted %%f successfully.
        ) else (
            echo Error deleting %%f.
        )
    ) else (
        echo %%f does not exist. Skipping.
    )
)




::1) Start tao_ft_naming
echo "==>Start Naming_Service"
start "tao_cosnaming" cmd /k " %TAO_ROOT%/orbsvcs/Naming_Service/tao_cosnaming -ORBdebuglevel -o %PROJECT_PATH%/ns.ior"
timeout /t 3

::2) Start tao_cosnotification
echo "==>Start tao_cosnotification"
start "tao_cosnotification" cmd /k "%TAO_ROOT%/orbsvcs/Notify_Service/tao_cosnotification -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior  -IORoutput %PROJECT_PATH%/notify.ior"
timeout /t 3

::3) Start MessengerServer
echo "==>Start MessengerServer"
start "MessengerServer" cmd /k "MessengerServer -ORBdebuglevel 0 -o %PROJECT_PATH%/Messenger.ior -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior"
timeout /t 3

::4) Start MessengerConsumer
echo "==>Start MessengerConsumer"
start "MessengerConsumer" cmd /k "MessengerConsumer -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior -k file://%PROJECT_PATH%/Messenger.ior"

::5) Start MessengerClient
echo "==>Start MessengerClient"
start "MessengerClient" cmd /k "MessengerClient -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior -k file://%PROJECT_PATH%/Messenger.ior"

pause >nul
@echo off

:: 使用通知通道将消息从供应者推送到消费者。使用结构化事件来展示通道的操作。示例采用了推送/推送模型。
:: MessengerServer充当MessengerClient的服务器角色，同时也是MessengerConsumer的供应者
:: MessengerClient -> MessengerSupplier(MessengerServer) -> NotificationChannel -> MessengerConsumer